package com.nuanshui.heatedloan.msgcenter.apppush;

import com.nuanshui.framework.springContext.SpringContextUtil;
import com.nuanshui.heatedloan.msgcenter.apppush.getui.GeTuiAppPush;
import com.nuanshui.heatedloan.msgcenter.apppush.getui.GeTuiConfig;
import com.nuanshui.heatedloan.msgcenter.model.AppPushMessage;

/**
 * 三方推送工厂类
 * @param 
 * @author guohao
 * @date 2017年2月10日 下午4:43:22
 * @since $
 */
public class AppPushFactory {


	private static GeTuiAppPush geTuiAppPush = null;

	private static GeTuiAppPush geTuiTestAppPush = null;

	private AppPushFactory() {
		
	}

	private  static void init() {
		if (geTuiAppPush == null) {
			GeTuiConfig releaseConfig = SpringContextUtil.getBean("releaseGeTuiConfig");
			GeTuiConfig testConfig = SpringContextUtil.getBean("testGeTuiConfig");
			geTuiAppPush = new GeTuiAppPush(releaseConfig);
			geTuiTestAppPush = new GeTuiAppPush(testConfig);
		}
	}
	
	/**
	 * 根据推送信息获取一个推送事例
	 * @param @param thirdPushMsgInfo
	 * @param @return
	 * @author guohao
	 * @date 2017年2月10日 下午4:46:05
	 * @since $
	 */
	public static  AppPush getAppPush(AppPushMessage msgInfo) {

		init();

		if(msgInfo.getMsgBody().getEnv() == null || msgInfo.getMsgBody().getEnv() == 0){//如果没有设置推送环境 或者获取为测试
			return geTuiTestAppPush;
		}
		return geTuiAppPush;
	}
	
	public static void main(String[] args) {

	}
}
